﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MenuPanel : BasePanel
{
	CanvasGroup canvasGroup;
	private void Awake() {
		canvasGroup = GetComponent<CanvasGroup>();
		uipanelType = UIPanelType.MenuPanel;
	}


	public override void OnEnter() {
		canvasGroup.blocksRaycasts = true;
		canvasGroup.alpha = 1;
		transform.SetAsLastSibling();
		GetComponent<RectTransform>().localScale = Vector3.one;
	}


	public override void OnExit() {
		canvasGroup.blocksRaycasts = false;
		canvasGroup.alpha = 0;
		GetComponent<RectTransform>().localScale = Vector3.zero;
	}

	public override void OnPause() {
		canvasGroup.blocksRaycasts = false;
	}

	public override void OnResume() {
		canvasGroup.blocksRaycasts = true;
	}


	public void OnClickDifferent(int dif) {
		uiMng.PopStack();       // Pop -> MenuPanel
		uiMng.PopStack();       // Pop -> ModePanel

		bool online = (uiMng.GetPanel(UIPanelType.ModePanel) as ModePanel).SelectOnline;
		if (!online) {      // 单机模式
			uiMng.PushStack(UIPanelType.GamePanel);
			GamePanel gamePanel = uiMng.GetPanel(UIPanelType.GamePanel) as GamePanel;
			gamePanel.CreateGrid(dif);
		} else {
			uiMng.PushStack(UIPanelType.LinkPanel);
			(uiMng.GetPanel(UIPanelType.LinkPanel) as LinkPanel).dif = dif;
		}


	}





}
